var xzdx = '',//选择对象
    zasd = '',//作案时段
    qrfs = '',//侵入方式
    zacrk = '',//作案进出口
    selectedIndex = 0,//操作的某一行
    arr = [];//作案出入口数据
//选择对象数据
$.ajax({
    type: 'get',
    url: baseUrls + 'xkdl',
    data: {dmx: '选择对象'},
    beforeSend: function(){
        Loading();
    },
    success: function(response){
        closeLoading();
        if(response.responseCode == '1000'){
            xzdx = '<option value="">请选择</option>';
            if(response.content.length > 0){
                for(var i = 0; i< response.content.length; i++){
                    xzdx += '<option value="'+ nulls(response.content[i].dmxs) +'">'+ nulls(response.content[i].dmxs) +'</option>';
                }
                $('#xzdx').html(xzdx);
            }
        }else{
            Msg('选择对象暂无数据,请联系管理员！');
        }
    },
    error: function(){
        closeLoading();
        Msg('选择对象暂无数据,请联系管理员！');
    }
})

//作案时段
$.ajax({
    type: 'get',
    url: baseUrls + 'xkdl',
    data: {dmx: '作案时段'},
    beforeSend: function(){
        Loading();
    },
    success: function(response){
        closeLoading();
        if(response.responseCode == '1000'){
            zasd = '<option value="">请选择</option>';
            if(response.content.length > 0){
                for(var i = 0; i< response.content.length; i++){
                    zasd += '<option value="'+ nulls(response.content[i].dmxs) +'">'+ nulls(response.content[i].dmxs) +'</option>';
                }
                $('#zasd').html(zasd);
            }
        }else{
            Msg('作案时段暂无数据,请联系管理员！');
        }
    },
    error: function(){
        closeLoading();
        Msg('作案时段暂无数据,请联系管理员！');
    }
})
//侵入方式
$.ajax({
    type: 'get',
    url: baseUrls + 'xkdl',
    data: {dmx: '侵入方式'},
    beforeSend: function(){
        Loading();
    },
    success: function(response){
        closeLoading();
        if(response.responseCode == '1000'){
            qrfs = '<option value="">请选择</option>';
            if(response.content.length > 0){
                for(var i = 0; i< response.content.length; i++){
                    qrfs += '<option value="'+ nulls(response.content[i].dmxs) +'">'+ nulls(response.content[i].dmxs) +'</option>';
                }
                $('#qrfs').html(qrfs);
                //模拟下拉框
                // $("#qrfs").M_select({
                //     "Img":"./thread/js/js/M_select/up1.png",
                //     "Img2":"./thread/js/js/M_select/down1.png",
                //     width: '100%',
                //     Succee:function(data){
                //         selectedIndex = 3;
                //         if(data != '请选择'){
                //             listDetail(data,'qrfs');
                //         }else{
                //             $('#clueSimulation').find('.clearfix').eq(selectedIndex).find('.chooseDateShow').val('');
                //             $('#clueSimulation').find('.clearfix').eq(selectedIndex).find('.chooseDateHide').val('');
                //         }
                //     }
                // });
            }
        }else{
            Msg('侵入方式暂无数据,请联系管理员！');
        }
    },
    error: function(){
        closeLoading();
        Msg('侵入方式暂无数据,请联系管理员！');
    }
})
//作案进出口
$.ajax({
    type: 'get',
    url: baseUrls + 'xkdl',
    data: {dmx: '作案出入口'},
    beforeSend: function(){
        Loading();
    },
    success: function(response){
        closeLoading();
        if(response.responseCode == '1000'){
            zacrk = '<option value="">请选择</option>';
            if(response.content.length > 0){
                for(var i = 0; i< response.content.length; i++){
                    zacrk += '<option value="'+ nulls(response.content[i].dmxs) +'">'+ nulls(response.content[i].dmxs) +'</option>';
                }
                $('#zark').html(zacrk);
                $('#zack').html(zacrk);
            }
        }else{
            Msg('作案进出口暂无数据,请联系管理员！');
        }
    },
    error: function(){
        closeLoading();
        Msg('作案进出口暂无数据,请联系管理员！');
    }
})//大类展示
function listDetail(item){
    var val = $(item).find('option:selected').val();
    layer.closeAll();
    if(val != '' && val != undefined){
        $(item).parent().parent().find('.chooseDl').val($(item).find('option:selected').val());
        $(item).find("option:first-child").prop("selected", 'selected');
        $.ajax({
            type: 'get',
            url: baseUrls + 'xkxl',
            data: {dmxs: val},
            beforeSend: function(){
                Loading();
            },
            success: function(response){
                closeLoading();
                if(response.responseCode == '1000'){
                    if(response.content.length > 1 && response.content[0] != null){
                        var Str = '',
                            heightBox = '',
                            length = '';
                        for(var i = 0; i < response.content.length; i++){
                            Str += '<option>'+ nulls(response.content[i].dmxt) +'</option>'
                        }
                        heightBox = response.content.length > 10 ? 10 * 26 + 145 : response.content.length * 26 + 145;
                        length = response.content.length > 10 ? 10 : 'auto';
                        layer.open({
                            title: val,
                            type: 1,
                            skin: 'layui-layer-rim', //加上边框
                            area: ['500px', heightBox + 'px'], //宽高
                            scrollbar: false,
                            shadeClose: true,
                            move: false,
                            content: '<select  class="selectpicker " multiple data-live-search="true">'+ Str +'</select>',
                            success: function (layero, index) {
                                $('.selectpicker').selectpicker({
                                    noneSelectedText: '请选择',
                                    countSelectedText:"已选中{0}项",
                                    selectedTextFormat:"count > 3",
                                    actionsBox: false,
                                    width: '100%',
                                    size: length,
                                    maxOptions: 10,
                                    maxOptionsText: function (numAll, numGroup) {
                                        return [
                                            (numAll == 1) ? '最多选择{n}项' : '最多选择{n}项',
                                            (numGroup == 1) ? '最多选择{n}组' : '最多选择{n}组'
                                        ];
                                    }
                                });
                            },
                            cancel: function(index, layero){
                                var str = $('.selectpicker').selectpicker('val').join(',');
                                if($('.selectpicker').selectpicker('val').length > 2){
                                    $(item).parent().parent().find('.chooseDateShow').val('已选中' + $('.selectpicker').selectpicker('val').length + '项');
                                }else{
                                    $(item).parent().parent().find('.chooseDateShow').val(str);
                                }
                                $(item).parent().parent().find('.chooseDateHide').val(str);
                                $('.selectpicker').selectpicker('destroy');
                            }
                        });
                    }else{
                        Msg(val + '无二级菜单');
                        $(item).parent().parent().find('.chooseDateShow').val('');
                        $(item).parent().parent().find('.chooseDateHide').val('');
                    }
                }else{
                    Msg(val + '无二级菜单！');
                    $(item).parent().parent().find('.chooseDateShow').val('');
                    $(item).parent().parent().find('.chooseDateHide').val('');
                }
            },
            error: function(){
                closeLoading();
                Msg(val + '获取失败！');
                $(item).parent().parent().find('.chooseDateShow').val('');
                $(item).parent().parent().find('.chooseDateHide').val('');
            }
        })
    }else{
        $(item).parent().parent().find('.chooseDl').val('');
    }
}